﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/MasterNhanSuTienLuong.Master" Inherits="System.Web.Mvc.ViewPage<DTTB.MV2.QUANLYNHANSUTIENLUONG.Models.FormBean.PhanQuyen.DepartmentsForm>" %>

<%@ Import Namespace="Webdiyer.WebControls.Mvc" %>
<%@ Import Namespace="DTTB.DTO" %>
<%@ Import Namespace="System.Web.Mvc.Html" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <script type="text/javascript" language="javascript" src="<%= ResolveUrl("~/Content/Scripts/Departments/Departments.js") %>"></script>
    <script language="javascript" type="text/javascript">
        $(document).ready(function() {
            selectMenu("HeThong-Departments");
            $("#HeThong-Departments").parent().attr("class", "active");
            $("#GiaTriSearch").focus();
        });
        
        $(function () {
            $("#box").dialog({
                autoOpen: false,
                modal: true,
                width: 400
            });

            $("#opener").click(function () {
                $("#box").dialog("open");
                return false;
            });
        });
    </script>
    
    
    

    <form id="form" method="post" action="#" class="formBox">

    <%=Html.Hidden("DepartmentID")%>
    <input type="hidden" id="IdChief" name="IdChief"/> <%--Chứa Id của user đựoc chọn làm Trưởng phòng--%>

    <div class="box">
         <div class="breadcrumbs">
          <ul>
            <li class="home"><a href="">Quản lý hệ thống</a></li>
            <li><a href="">Quản lý Phòng ban</a></li>
            <li>Page</li>
          </ul>
        </div>
           <div class="headlines">
            <h2>
                <span>Quản lý Phòng ban</span>
            </h2>
               <%-- <a class="show-filter" href="#">show filter</a>--%>
        </div>
		    
            <table class="table_outsite" width="100%">
                    
                    <tr>
                        <td >
                            <%--Thông Báo--%>
                            <%
                                if (Model.MessageCreateDepartments != null)
                                {
                            %>
                            <div id="MessageCreateDepartments" style="font-size: 12px; color: Blue; font-weight: bold">
                                <%=Model.MessageCreateDepartments %></div>
                            <%
                                }
                            %>
                            <%
                                if (Model.MessageEditDepartments != null)
                                {
                            %>
                            <div id="MessageEditDepartments" style="font-size: 12px; color: Blue; font-weight: bold">
                                <%=Model.MessageEditDepartments %></div>
                            <%
                                }
                            %>
                            <%--end--%>
                        </td>
                        <td align="right" class="btn-submit">
                            <input type="button"class="button" value="Tạo/Cập nhật" onclick="DoCreateOrEdit()" />
                            <input type="button"class="button" value="Tạo mới" onclick="javascript:DoNewAjax();" />
                            <input type="button"class="button" value="Xóa" onclick="javascript:DoDelete();" />
                            <input type="button"class="button" value="Nhập lại" onclick="javascript:DoReset();" />
                        </td>
                    </tr>
                </table >
                <table class="table_input" width="100%">
                    <tr>
                        <td nowrap="nowrap">
                            <%--Mã phòng ban :--%>
                        </td>
                        <td colspan="3">
                            <%--<input type="text" name="IdDepartmment" id="IdDepartmment" readonly="readonly" value='<%=Model.ID %>' width="70%" />--%>
                            <input type="hidden" name="IdDepartmment" id="IdDepartmment" value='<%=Model.ID %>'/>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 13%" nowrap="nowrap">
                            <b>Tên phòng ban:</b>
                        </td>
                        <td style="width: 50%">
                            <input type="text" style="width:80%" value="<%=Model.DepartmentName%>" id="DepartmentName" name="DepartmentName" />
                                
                            <div id="DepartmentNameMessage" class="red"></div>
                        </td>
                        <td style="width: 12%" nowrap="nowrap">
                            Ngày tạo:
                        </td>
                        <td style="width: 25%">
                            <input  type="text"name="CreateDate" id="CreateDate"  width="70%" disabled="disabled"  value="<%=Model.CreateDate.ToString("dd/MM/yyyy")%>" />
                        </td>
                        
                    </tr>
                    <tr>
                         <td nowrap="nowrap">
                            <b>Mô tả:</b>
                        </td>
                        <td>
                            <input type="text"  style="width:80%" id="DepartmentDesc" name="DepartmentDesc" value="<%=Model.DepartmentDesc%>"/>
                        </td>
                        <td nowrap="nowrap">
                            Ngày cập nhật:
                        </td>
                        <td>
                            <input type="text" width="70%" id="UpdateDate" disabled="disabled" value='<%=Model.UpdateDate.ToString("dd/MM/yyyy")%>' />
                        </td>
                    </tr>
                    <tr>
                        <td nowrap="nowrap">
                           <b>Trưởng phòng:</b>
                        </td>
                        <td>
                            <input type="text"  style="width:66%" id="Chief" name="Chief" readonly="readonly" value="<%=Model.Chief%>" />
                            <input type="button" id="opener" name="opener" value="Chọn..." />
                        </td>
                        <td nowrap="nowrap">
                            Người tạo:
                        </td>
                        <td>
                            <input type="text"  name="CreateBy" id="CreateBy" width="70%" disabled="disabled" value="<%=Model.CreateByUser%>" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2"></td>
                        <td nowrap="nowrap">
                            Người cập nhật:
                        </td>
                        <td>
                            <input type="text" width="70%" id="UpdateBy" disabled="disabled" value='<%=Model.UpdateByUser%>' />
                        </td>
                    </tr>
                    <tr><td colspan="4">&nbsp;</td></tr> 
                    <%--<tr>
                        <td colspan="4" align="right">
                            <input type="button" value="Tạo/Cập nhật" onclick="DoCreateOrEdit()" />
                            <input type="button" value="Tạo mới" onclick="javascript:DoNewAjax();" />
                            <input type="button" value="Xóa" onclick="javascript:DoDelete();" />
                            <input type="button" value="Nhập lại" onclick="javascript:DoReset();" />
                        </td>
                    </tr>--%>
                </table>
            
            <div class="pagebreak"> &nbsp;</div>

            <table class="table_outsite" width="100%">
                <tr>
                    <td colspan="2" class="first">
                        &nbsp;<b>Danh sách Phòng ban:</b>
                    </td>
                    <td colspan="2" class="first" align="right">
                        <%=Html.DropDownList("TieuChiSearch", Model.TieuChiSearchDropDownList)%>
                        <%=Html.TextBox("GiaTriSearch", Model.GiaTriSearch, new { @onkeypress = "if (event.keyCode==13) { return DoSearch(); }", Style = "width:210px" })%>
                        <img onclick="javascript:DoSearch();" style="vertical-align: middle; cursor:pointer" src="<%=ResolveUrl("~/Content/ImagesAdmin/search_icon.gif")%>"
                            alt="Tìm phòng ban" title="Tìm phòng ban"/>
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <table cellspacing="0" cellpadding="0"  class="tab tab-drag">
                            <tr class="top nodrop nodrag" style="font-weight: bold">
                                <td width="8%" class="first" align="center">
                                    &nbsp;<strong>STT</strong>
                                </td>
                                <td nowrap="nowrap">
                                    <strong>Tên phòng ban</strong>
                                </td>
                                <td align="left" nowrap="nowrap">
                                    <strong>Mô tả</strong>
                                </td>
                                <td width="12%" nowrap="nowrap">
                                    <strong>Ngày cập nhật</strong>
                                </td>
                                <td class="last" nowrap="nowrap">
                                    <strong>Người cập nhật</strong>
                                </td>
                            </tr>
                            <%--Departments List--%>
                            <%
                                
                           IList<DepartmentsDto> DepartmentsDtoList = Model.DepartmentsPagedList;
                           int dem = 0;
                           foreach (DepartmentsDto dto in DepartmentsDtoList)
                            {
                            %>
                            <tr class="item_row" onclick="javascript:highlight(this);EditDepartmentsAjax(<%=dto.ID%>);">
                                <td class="first" align="center">
                                    <%=++dem%>
                                </td>
                                <td align="left">
                                    <%=dto.DepartmentName%>&nbsp;
                                </td>
                                <td align="left">
                                    <%=dto.DepartmentDesc %>
                                </td>
                                <td align="left">
                                    <%=dto.UpdateDate.ToString("dd/MM/yyyy")%>&nbsp;
                                </td>
                                <td class="last">
                                    <%=dto.UpdateByUser%>&nbsp;
                                </td>
                            </tr>
                            <%}
                            %>
                            <tr class="border_bottom">
                                <td class="first" style="background: #DDDDDD">
                                </td>
                                <td class="last" colspan="7" align="right" style="background: #DDDDDD; padding-right: 10px">
                                     
                                     <%
                                     
                                     PagerOptions pagerOptions = new PagerOptions();
                                     pagerOptions.PageIndexParameterName = "id";
                                     pagerOptions.NextPageText = "Tiếp";
                                     %>
                                    <div><%=Html.Pager(Model.DepartmentsPagedList,pagerOptions) %></div>
                                    <%=Html.Hidden("PageNumber", Model.PageNumber)%>
                                </td>
                            </tr>
                            <%--dã xóa--%>
                        </table>
                    </td>
                </tr>
            </table>
            
           
       <%-- </div>--%>
    </div>
    <%--<%Html.EndForm(); %>--%>

    </form>
    
    

    <%-- Box chọn trưởng phòng --%>
    <div title="Chọn Trưởng Phòng" id="box">              
        <form id = "form1" method="post" action="<%=ResolveUrl("") %>" target="_parent">
            <div style="margin: 0px 0px 5px 5px"></div>
                <table class="table_input" width="100%">
                    <tr>
                        <td>
                            <%
                            if(Model.IdChiefList.Count() > 7)
                            {
                            %>
                            <div style='width:100%; height:440px; overflow:auto'>   
                            <%    
                            }
                            else
                            {
                            %>
                            <div style='width:100%; height:auto; overflow:auto'>   
                            <%
                            }
                            %>
                                <table width="100%">
                                    <%
                                        for (int i = 0; i < Model.IdChiefList.Count(); i++)
                                        {
                                            var item = Model.IdChiefList.ElementAt(i);
                                        %>
                                                <tr>
                                                                                  
                                            <td width="7%">
                                                <input type="radio" id="Radio" name="RadioTruongPhong" value="<%=item.ID %>" style="cursor:pointer"/>
                                            </td >
                                            <td width="43%">
                                                <%
                                                if(item.Sex == true)
                                                {
                                                    %><img src="<%=ResolveUrl("~/Content/ImagesAdmin/User.png")%>" /><%
                                                }
                                                else
                                                {
                                                    %><img src="<%=ResolveUrl("~/Content/ImagesAdmin/User_Female.png")%>" /><%
                                                }
                                                %>&nbsp;
                                                <a><%= (string.IsNullOrEmpty(item.FullName)) ? item.UserName : item.FullName%></a>
                                            </td>
                                            
                                                </tr>
                                                                            
                                        <%
                                        }     
                                        %>
                                        <%
                                        if(Model.IdChiefList.Count() != 0)
                                        {
                                            %>
                                            <tr>
                                                <td>
                                                    <input type="radio" id="Radio1" name="RadioTruongPhong" value="0" style="cursor:pointer"/>
                                                </td>
                                                <td>
                                                    [ Bỏ chọn trưởng phòng ]
                                                </td>
                                            </tr>
                                            <%
                                        }
                                        %>
                                </table>  
                            </div>
                        </td>
                    </tr>
                </table>
            <br/>
            <div align="right">
                <input type="button" name="cancel" value="Đồng ý" onclick="javascript:DoChonTruongPhong();"/>&nbsp;
                <input type="button" name="cancel" value="Hủy thao tác" onclick="javascript:$('#box').dialog('close');"/>
            </div>
        </form>
    </div>
    

</asp:Content>
